<?php
// +----------------------------------------------------------------------
// | tpapi.
// +----------------------------------------------------------------------
// | FileName: Setting.php
// +----------------------------------------------------------------------
// | Author: King east <1207877378@qq.com>
// +----------------------------------------------------------------------


namespace ke\thinkApi\src;


/**
 * Class Setting
 * @package ke\thinkApi
 * @method void setPk($str)
 * @method void setLimit($value)
 * @method void setVersion($value)
 * @method void setResponse($response)
 * @property-read integer pk
 * @property-read integer limit
 * @property-read string version
 */
class Setting
{
    private $config = [
        'pk'=>'id',
        'limit'=>100,
        'version'=>'v1'
    ];

    public function response($content, $code = 200)
    {
        if (!isset($this->config['response'])) {
            return json($content);
        }
        return $this->config['response']($content, $code);
    }

    public function __call($name, $arguments)
    {
        $name = strtolower(substr($name, 3));
        $this->config[$name] = $arguments[0];
        return $this;
    }


    public function __get($name)
    {
        if (isset($this->config[$name])) {
            return $this->config[$name];
        }
    }


}
